{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "d:\\Anacoonda\\envs\\CX_universe\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training_arrays_v1.py:37: UserWarning: A NumPy version >=1.23.5 and <2.3.0 is required for this version of SciPy (detected version 1.23.0)\n",
      "  from scipy.sparse import issparse  # pylint: disable=g-import-not-at-top\n"
     ]
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "from tensorflow.keras.layers import Input, Dense, MultiHeadAttention, LayerNormalization, Dropout, Embedding, Flatten\n",
    "from tensorflow.keras.models import Model\n",
    "from tensorflow.keras.optimizers import Adam\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def parse_next(x):\n",
    "    e = {'+':0,'-':0,'*':1,'/':1}\n",
    "    current_order = 0\n",
    "    operators = []\n",
    "    parameters = []\n",
    "    orders = []\n",
    "    s = ''\n",
    "    for i,j in enumerate(x):\n",
    "        if j=='(':\n",
    "            current_order += 2\n",
    "            s += j\n",
    "        elif j==')':\n",
    "            current_order -= 2\n",
    "            s += j\n",
    "        elif j in e:\n",
    "            operators.append(j)\n",
    "            orders.append(current_order+e[j])\n",
    "            parameters.append(s)\n",
    "            s = ''\n",
    "        else:\n",
    "            s += j\n",
    "    parameters.append(s)\n",
    "    if len(operators)<=1:\n",
    "        return x\n",
    "    else:\n",
    "        d = np.argmax(orders)\n",
    "        a = parameters[d].replace('(','').replace(')','')\n",
    "        b = parameters[d+1].replace('(','').replace(')','')\n",
    "        p = f'{a}{operators[d]}{b}'\n",
    "        c = x.replace(p,'&').replace('(&)','&')\n",
    "        return f'{p}|{c}'\n",
    "def parse(x):\n",
    "    result = parse_next(x)\n",
    "    if '|' not in result:\n",
    "        #continue\n",
    "        result = str(eval(x))\n",
    "        #print(result)\n",
    "        X.append(x)\n",
    "        Y.append(x)\n",
    "        return result\n",
    "    else:\n",
    "        #print(result)\n",
    "        X.append(x)\n",
    "        Y.append(result)\n",
    "        a,b = result.split('|')\n",
    "        c = str(eval(a))\n",
    "        d = b.replace('&',c)\n",
    "        parse(d)\n",
    "tmp = []\n",
    "X = []\n",
    "Y = []\n",
    "def generate_expression(max_depth=3,max_value=10):\n",
    "    if max_depth == 0:\n",
    "        return str(np.random.randint(0,max_value))\n",
    "    else:\n",
    "        operators = ['+','*']\n",
    "        operator = np.random.choice(operators)\n",
    "        left_expr = generate_expression(max_depth-1, max_value)\n",
    "        right_expr = generate_expression(max_depth-1, max_value)\n",
    "        if operator in ['*','-'] or np.random.choice([True,False]):\n",
    "            result = f\"({left_expr}{operator}{right_expr})\"\n",
    "        else:\n",
    "            result = f\"{left_expr}{operator}{right_expr}\"\n",
    "        return result\n",
    "tokenizer = tf.keras.preprocessing.text.Tokenizer(char_level=True)\n",
    "tokenizer.fit_on_texts(['0123456789+*()|&'])\n",
    "def data_generator(batchsize):\n",
    "    global X,Y\n",
    "    while 1:\n",
    "        if len(X)<batchsize:\n",
    "            try:\n",
    "                er = 3\n",
    "                parse(generate_expression(er,100))\n",
    "            except:\n",
    "                X = []\n",
    "                Y = []\n",
    "        else:\n",
    "            a = X[:batchsize]\n",
    "            b = Y[:batchsize]\n",
    "            X = X[batchsize:]\n",
    "            Y = Y[batchsize:]\n",
    "            a = tf.keras.preprocessing.sequence.pad_sequences(tokenizer.texts_to_sequences(a),padding='post',maxlen=100)\n",
    "            b = tf.keras.preprocessing.sequence.pad_sequences(tokenizer.texts_to_sequences(b),padding='post',maxlen=100)\n",
    "            yield [a,b]\n",
    "data_g = data_generator(32)\n",
    "def compute(equation,debug=False):\n",
    "    result = model.predict(tf.keras.preprocessing.sequence.pad_sequences(tokenizer.texts_to_sequences([equation]),padding='post',maxlen=100),verbose=0)\n",
    "    result = tokenizer.sequences_to_texts(np.argmax(result,axis=-1))[0].replace(' ','')\n",
    "    if debug:\n",
    "        print('#debug: ',result)\n",
    "    if '|' not in result:\n",
    "        print(f'{equation} = {eval(result)}')\n",
    "    else:\n",
    "        a,b = result.split('|')\n",
    "        a_result = str(eval(a))\n",
    "        print(f'{a} = {a_result}')\n",
    "        c = b.replace('&',a_result)\n",
    "        print(f'{equation} = {c}')\n",
    "        compute(c,debug)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "class TransformerBlock(tf.keras.layers.Layer):\n",
    "    def __init__(self, embed_dim, num_heads, ff_dim, rate=0.1):\n",
    "        super(TransformerBlock, self).__init__()\n",
    "        self.att = MultiHeadAttention(num_heads=num_heads, key_dim=embed_dim)\n",
    "        self.ffn = tf.keras.Sequential([Dense(ff_dim, activation=\"relu\"), Dense(embed_dim),])\n",
    "        self.layernorm1 = LayerNormalization(epsilon=1e-6)\n",
    "        self.layernorm2 = LayerNormalization(epsilon=1e-6)\n",
    "        self.dropout1 = Dropout(rate)\n",
    "        self.dropout2 = Dropout(rate)\n",
    "    def call(self,inputs,training):\n",
    "        attn_output = self.att(inputs,inputs)\n",
    "        attn_output = self.dropout1(attn_output,training=training)\n",
    "        out1 = self.layernorm1(inputs+attn_output)\n",
    "        ffn_output = self.ffn(out1)\n",
    "        ffn_output = self.dropout2(ffn_output,training=training)\n",
    "        return self.layernorm2(out1+ffn_output)\n",
    "class TransformerBlock2(tf.keras.layers.Layer):\n",
    "    def __init__(self, embed_dim, num_heads, ff_dim, rate=0.1):\n",
    "        super(TransformerBlock2, self).__init__()\n",
    "        self.att = MultiHeadAttention(num_heads=num_heads, key_dim=embed_dim)\n",
    "        self.ffn = tf.keras.Sequential([Dense(ff_dim, activation=\"relu\"), Dense(embed_dim),])\n",
    "        self.layernorm1 = LayerNormalization(epsilon=1e-6)\n",
    "        self.layernorm2 = LayerNormalization(epsilon=1e-6)\n",
    "        self.dropout1 = Dropout(rate)\n",
    "        self.dropout2 = Dropout(rate)\n",
    "    def call(self,inputs,training):\n",
    "        attn_output = self.att(inputs[0],inputs[1])\n",
    "        attn_output = self.dropout1(attn_output,training=training)\n",
    "        out1 = self.layernorm1(inputs[0]+attn_output)\n",
    "        ffn_output = self.ffn(out1)\n",
    "        ffn_output = self.dropout2(ffn_output, training=training)\n",
    "        return self.layernorm2(out1+ffn_output)\n",
    "def get_model(input_shape,output_shape,tokenizer,embed_dim=32,p1=[[8,32],[16,32]],p2=[[16,32],[8,32]]):\n",
    "    x_position_embedding = Embedding(input_dim=input_shape[0],output_dim=embed_dim)(np.array([i for i in range(input_shape[0])]).reshape(1,-1))\n",
    "    x = Input(shape=input_shape)\n",
    "    input_embedding = Embedding(input_dim=len(tokenizer.word_index)+1,output_dim=embed_dim)(x)\n",
    "    knowledge = input_embedding+x_position_embedding\n",
    "    for i in p1:\n",
    "        knowledge = TransformerBlock(embed_dim,i[0],i[1])(knowledge)+x_position_embedding\n",
    "    y_position_embedding = Embedding(input_dim=output_shape[0],output_dim=embed_dim)(np.array([i for i in range(output_shape[0])]).reshape(1,-1))\n",
    "    answer = tf.tile(knowledge[:,:1,:],[1,output_shape[0],1])*0+y_position_embedding\n",
    "    for i in p2:\n",
    "        answer = TransformerBlock2(embed_dim,i[0],i[1])([answer,knowledge])+y_position_embedding\n",
    "    y = Dense(len(tokenizer.word_index)+1,activation=\"softmax\")(answer)\n",
    "    return Model(inputs=x,outputs=y)\n",
    "class CX_LOSS(tf.losses.Loss):\n",
    "    def __init__(self, num_classes=80, alpha=0.25, gamma=2.0, delta=1.0):\n",
    "        super().__init__(reduction=\"auto\", name=\"RetinaNetLoss\")\n",
    "        self.l = tf.keras.losses.CategoricalCrossentropy()\n",
    "    def call(self,y_true,y_pred):\n",
    "        loss = self.l(tf.one_hot(y_true,len(tokenizer.word_index)+1),y_pred)\n",
    "        loss = tf.where(y_true==0,0.1*loss,5*loss)\n",
    "        return tf.reduce_sum(loss,axis=-1)\n",
    "model = get_model((100,),(100,),tokenizer,embed_dim=128,p1=[[4,128],[8,128],[16,128],[32,128]],p2=[[32,128],[16,128],[8,128],[4,128]])\n",
    "model.compile(optimizer=Adam(learning_rate=1e-4),loss=CX_LOSS(),metrics=['accuracy'])\n",
    "def focal_loss(gamma=2.0, alpha=0.25):\n",
    "    def focal_loss_func(y_true, y_pred):\n",
    "        y_true = tf.cast(tf.one_hot(y_true,len(tokenizer.word_index)+1), dtype=tf.float32)\n",
    "        y_pred = tf.cast(y_pred, dtype=tf.float32)\n",
    "        epsilon = tf.keras.backend.epsilon()\n",
    "        y_pred = tf.clip_by_value(y_pred, epsilon, 1. - epsilon)\n",
    "        cross_entropy = -y_true * tf.math.log(y_pred) - (1 - y_true) * tf.math.log(1 - y_pred)\n",
    "        alpha_factor = y_true * alpha + (1 - y_true) * (1 - alpha)\n",
    "        modulating_factor = tf.pow((1.0 - y_true) * y_pred + y_true * (1.0 - y_pred), gamma)\n",
    "        loss = alpha_factor * modulating_factor * cross_entropy\n",
    "        return tf.reduce_mean(tf.reduce_sum(loss,axis=-1))\n",
    "    return focal_loss_func\n",
    "#model.compile(optimizer=Adam(learning_rate=3e-4),loss=focal_loss(),metrics=['accuracy'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "model.load_weights('inducer')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "model.save_weights('inducer')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\陈旭\\AppData\\Local\\Temp\\ipykernel_3372\\3623271469.py:2: UserWarning: `Model.fit_generator` is deprecated and will be removed in a future version. Please use `Model.fit`, which supports generators.\n",
      "  history = model.fit_generator(data_g,steps_per_epoch=100,epochs=500)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/500\n",
      "100/100 [==============================] - 29s 117ms/step - loss: 147.5354 - accuracy: 0.7638\n",
      "Epoch 2/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 136.0614 - accuracy: 0.7723\n",
      "Epoch 3/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 91.1391 - accuracy: 0.7926\n",
      "Epoch 4/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 76.2874 - accuracy: 0.8090\n",
      "Epoch 5/500\n",
      "100/100 [==============================] - 11s 110ms/step - loss: 70.1172 - accuracy: 0.8175\n",
      "Epoch 6/500\n",
      "100/100 [==============================] - 11s 113ms/step - loss: 70.0851 - accuracy: 0.8173\n",
      "Epoch 7/500\n",
      "100/100 [==============================] - 12s 117ms/step - loss: 68.7341 - accuracy: 0.8196\n",
      "Epoch 8/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 67.7375 - accuracy: 0.8212\n",
      "Epoch 9/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 65.8459 - accuracy: 0.8242\n",
      "Epoch 10/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 65.0116 - accuracy: 0.8255\n",
      "Epoch 11/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 62.8739 - accuracy: 0.8282\n",
      "Epoch 12/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 63.0354 - accuracy: 0.8280\n",
      "Epoch 13/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 62.7820 - accuracy: 0.8280\n",
      "Epoch 14/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 62.3136 - accuracy: 0.8286\n",
      "Epoch 15/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 61.6458 - accuracy: 0.8293\n",
      "Epoch 16/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 60.9162 - accuracy: 0.8302\n",
      "Epoch 17/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 60.8896 - accuracy: 0.8303\n",
      "Epoch 18/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 59.8405 - accuracy: 0.8322\n",
      "Epoch 19/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 60.2807 - accuracy: 0.8318\n",
      "Epoch 20/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 59.1531 - accuracy: 0.8329\n",
      "Epoch 21/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 59.5199 - accuracy: 0.8330\n",
      "Epoch 22/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 59.0073 - accuracy: 0.8335\n",
      "Epoch 23/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 59.2444 - accuracy: 0.8343\n",
      "Epoch 24/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 58.1052 - accuracy: 0.8354\n",
      "Epoch 25/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 57.9659 - accuracy: 0.8362\n",
      "Epoch 26/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 58.3701 - accuracy: 0.8370\n",
      "Epoch 27/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 57.1749 - accuracy: 0.8393\n",
      "Epoch 28/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 56.1249 - accuracy: 0.8417\n",
      "Epoch 29/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 53.8049 - accuracy: 0.8465\n",
      "Epoch 30/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 53.3763 - accuracy: 0.8493\n",
      "Epoch 31/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 51.6434 - accuracy: 0.8524\n",
      "Epoch 32/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 50.0191 - accuracy: 0.8588\n",
      "Epoch 33/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 48.1896 - accuracy: 0.8641\n",
      "Epoch 34/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 46.3629 - accuracy: 0.8709\n",
      "Epoch 35/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 44.4705 - accuracy: 0.8775\n",
      "Epoch 36/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 42.3693 - accuracy: 0.8856\n",
      "Epoch 37/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 39.8084 - accuracy: 0.8937\n",
      "Epoch 38/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 36.7427 - accuracy: 0.9016\n",
      "Epoch 39/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 35.0330 - accuracy: 0.9076\n",
      "Epoch 40/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 34.3322 - accuracy: 0.9089\n",
      "Epoch 41/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 32.6628 - accuracy: 0.9142\n",
      "Epoch 42/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 32.1488 - accuracy: 0.9164\n",
      "Epoch 43/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 30.9942 - accuracy: 0.9180\n",
      "Epoch 44/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 30.1189 - accuracy: 0.9203\n",
      "Epoch 45/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 28.6814 - accuracy: 0.9237\n",
      "Epoch 46/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 27.8580 - accuracy: 0.9263\n",
      "Epoch 47/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 26.1705 - accuracy: 0.9312\n",
      "Epoch 48/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 25.9630 - accuracy: 0.9318\n",
      "Epoch 49/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 26.1159 - accuracy: 0.9303\n",
      "Epoch 50/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 25.1714 - accuracy: 0.9337\n",
      "Epoch 51/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 24.2754 - accuracy: 0.9357\n",
      "Epoch 52/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 23.8083 - accuracy: 0.9373\n",
      "Epoch 53/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 23.3764 - accuracy: 0.9386\n",
      "Epoch 54/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 22.8466 - accuracy: 0.9395\n",
      "Epoch 55/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 22.1270 - accuracy: 0.9410\n",
      "Epoch 56/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 20.6800 - accuracy: 0.9452\n",
      "Epoch 57/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 21.5838 - accuracy: 0.9428\n",
      "Epoch 58/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 20.0754 - accuracy: 0.9473\n",
      "Epoch 59/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 19.8906 - accuracy: 0.9466\n",
      "Epoch 60/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 18.9914 - accuracy: 0.9492\n",
      "Epoch 61/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 19.3657 - accuracy: 0.9479\n",
      "Epoch 62/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 18.8964 - accuracy: 0.9493\n",
      "Epoch 63/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 18.6835 - accuracy: 0.9495\n",
      "Epoch 64/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 17.9544 - accuracy: 0.9510\n",
      "Epoch 65/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 18.2034 - accuracy: 0.9514\n",
      "Epoch 66/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 17.2145 - accuracy: 0.9539\n",
      "Epoch 67/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 16.9382 - accuracy: 0.9553\n",
      "Epoch 68/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 15.5896 - accuracy: 0.9579\n",
      "Epoch 69/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 15.8364 - accuracy: 0.9570\n",
      "Epoch 70/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 16.4952 - accuracy: 0.9554\n",
      "Epoch 71/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 15.6258 - accuracy: 0.9579\n",
      "Epoch 72/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 15.3439 - accuracy: 0.9586\n",
      "Epoch 73/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 15.6097 - accuracy: 0.9583\n",
      "Epoch 74/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 14.8998 - accuracy: 0.9601\n",
      "Epoch 75/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 14.5978 - accuracy: 0.9603\n",
      "Epoch 76/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 13.4304 - accuracy: 0.9629\n",
      "Epoch 77/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 13.8086 - accuracy: 0.9629\n",
      "Epoch 78/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 13.5138 - accuracy: 0.9633\n",
      "Epoch 79/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 13.4053 - accuracy: 0.9632\n",
      "Epoch 80/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 13.2970 - accuracy: 0.9642\n",
      "Epoch 81/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 12.5286 - accuracy: 0.9661\n",
      "Epoch 82/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 12.7566 - accuracy: 0.9646\n",
      "Epoch 83/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 11.6369 - accuracy: 0.9677\n",
      "Epoch 84/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 12.5029 - accuracy: 0.9661\n",
      "Epoch 85/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 11.3236 - accuracy: 0.9694\n",
      "Epoch 86/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 11.9218 - accuracy: 0.9674\n",
      "Epoch 87/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 11.5650 - accuracy: 0.9684\n",
      "Epoch 88/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 10.7554 - accuracy: 0.9713\n",
      "Epoch 89/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 11.6886 - accuracy: 0.9678\n",
      "Epoch 90/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 10.4411 - accuracy: 0.9713\n",
      "Epoch 91/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 10.5739 - accuracy: 0.9710\n",
      "Epoch 92/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 10.6506 - accuracy: 0.9704\n",
      "Epoch 93/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 10.2082 - accuracy: 0.9727\n",
      "Epoch 94/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 9.8509 - accuracy: 0.9729\n",
      "Epoch 95/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 9.6044 - accuracy: 0.9737\n",
      "Epoch 96/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 9.3568 - accuracy: 0.9742\n",
      "Epoch 97/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 9.0841 - accuracy: 0.9756\n",
      "Epoch 98/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 9.4090 - accuracy: 0.9741\n",
      "Epoch 99/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 8.8375 - accuracy: 0.9759\n",
      "Epoch 100/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 8.9380 - accuracy: 0.9753\n",
      "Epoch 101/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 8.6394 - accuracy: 0.9765\n",
      "Epoch 102/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 8.7344 - accuracy: 0.9759\n",
      "Epoch 103/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 8.8124 - accuracy: 0.9760\n",
      "Epoch 104/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 8.2520 - accuracy: 0.9777\n",
      "Epoch 105/500\n",
      "100/100 [==============================] - 12s 123ms/step - loss: 7.7396 - accuracy: 0.9791\n",
      "Epoch 106/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 8.0340 - accuracy: 0.9778\n",
      "Epoch 107/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 7.5190 - accuracy: 0.9791\n",
      "Epoch 108/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 7.8003 - accuracy: 0.9792\n",
      "Epoch 109/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 7.6514 - accuracy: 0.9791\n",
      "Epoch 110/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 7.7196 - accuracy: 0.9802\n",
      "Epoch 111/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 8.2740 - accuracy: 0.9774\n",
      "Epoch 112/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 7.1858 - accuracy: 0.9810\n",
      "Epoch 113/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 6.9781 - accuracy: 0.9810\n",
      "Epoch 114/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 6.4308 - accuracy: 0.9823\n",
      "Epoch 115/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 6.8017 - accuracy: 0.9820\n",
      "Epoch 116/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 7.1934 - accuracy: 0.9806\n",
      "Epoch 117/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 7.0219 - accuracy: 0.9810\n",
      "Epoch 118/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 5.7814 - accuracy: 0.9841\n",
      "Epoch 119/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 5.9373 - accuracy: 0.9842\n",
      "Epoch 120/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 6.2825 - accuracy: 0.9832\n",
      "Epoch 121/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 6.3283 - accuracy: 0.9833\n",
      "Epoch 122/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 6.3049 - accuracy: 0.9829\n",
      "Epoch 123/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 7.0707 - accuracy: 0.9816\n",
      "Epoch 124/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 5.9249 - accuracy: 0.9840\n",
      "Epoch 125/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 6.2382 - accuracy: 0.9828\n",
      "Epoch 126/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 5.8013 - accuracy: 0.9844\n",
      "Epoch 127/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 5.8078 - accuracy: 0.9846\n",
      "Epoch 128/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 5.6315 - accuracy: 0.9848\n",
      "Epoch 129/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 5.2316 - accuracy: 0.9861\n",
      "Epoch 130/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 5.3222 - accuracy: 0.9856\n",
      "Epoch 131/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 5.7076 - accuracy: 0.9844\n",
      "Epoch 132/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 5.0812 - accuracy: 0.9859\n",
      "Epoch 133/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 6.4489 - accuracy: 0.9841\n",
      "Epoch 134/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 6.0898 - accuracy: 0.9839\n",
      "Epoch 135/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 4.9791 - accuracy: 0.9866\n",
      "Epoch 136/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 4.6980 - accuracy: 0.9872\n",
      "Epoch 137/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 5.1703 - accuracy: 0.9862\n",
      "Epoch 138/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 5.0499 - accuracy: 0.9864\n",
      "Epoch 139/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 4.7542 - accuracy: 0.9871\n",
      "Epoch 140/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 4.5945 - accuracy: 0.9877\n",
      "Epoch 141/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 4.8045 - accuracy: 0.9873\n",
      "Epoch 142/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 4.8002 - accuracy: 0.9873\n",
      "Epoch 143/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 4.7543 - accuracy: 0.9873\n",
      "Epoch 144/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 4.6564 - accuracy: 0.9873\n",
      "Epoch 145/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 4.5775 - accuracy: 0.9878\n",
      "Epoch 146/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 4.6087 - accuracy: 0.9879\n",
      "Epoch 147/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 3.9121 - accuracy: 0.9896\n",
      "Epoch 148/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 4.0671 - accuracy: 0.9890\n",
      "Epoch 149/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 4.4697 - accuracy: 0.9883\n",
      "Epoch 150/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 4.4413 - accuracy: 0.9890\n",
      "Epoch 151/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 4.0469 - accuracy: 0.9893\n",
      "Epoch 152/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 5.9326 - accuracy: 0.9846\n",
      "Epoch 153/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 4.5894 - accuracy: 0.9878\n",
      "Epoch 154/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 3.8553 - accuracy: 0.9898\n",
      "Epoch 155/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 3.7971 - accuracy: 0.9900\n",
      "Epoch 156/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 3.7549 - accuracy: 0.9904\n",
      "Epoch 157/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 3.4491 - accuracy: 0.9906\n",
      "Epoch 158/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 3.5837 - accuracy: 0.9906\n",
      "Epoch 159/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 3.8404 - accuracy: 0.9898\n",
      "Epoch 160/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 4.2189 - accuracy: 0.9889\n",
      "Epoch 161/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 3.7521 - accuracy: 0.9908\n",
      "Epoch 162/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 4.2454 - accuracy: 0.9888\n",
      "Epoch 163/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 3.6853 - accuracy: 0.9903\n",
      "Epoch 164/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 3.5650 - accuracy: 0.9910\n",
      "Epoch 165/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 3.7010 - accuracy: 0.9905\n",
      "Epoch 166/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 3.2345 - accuracy: 0.9918\n",
      "Epoch 167/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 3.2337 - accuracy: 0.9914\n",
      "Epoch 168/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 3.4401 - accuracy: 0.9907\n",
      "Epoch 169/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 3.7131 - accuracy: 0.9905\n",
      "Epoch 170/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 3.3875 - accuracy: 0.9910\n",
      "Epoch 171/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 4.1437 - accuracy: 0.9899\n",
      "Epoch 172/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 3.7030 - accuracy: 0.9904\n",
      "Epoch 173/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 3.5260 - accuracy: 0.9911\n",
      "Epoch 174/500\n",
      "100/100 [==============================] - 12s 117ms/step - loss: 3.1308 - accuracy: 0.9916\n",
      "Epoch 175/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 2.8576 - accuracy: 0.9926\n",
      "Epoch 176/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 2.9316 - accuracy: 0.9928\n",
      "Epoch 177/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 3.4790 - accuracy: 0.9915\n",
      "Epoch 178/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 3.4639 - accuracy: 0.9913\n",
      "Epoch 179/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 3.2545 - accuracy: 0.9916\n",
      "Epoch 180/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 2.8940 - accuracy: 0.9929\n",
      "Epoch 181/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 3.2933 - accuracy: 0.9917\n",
      "Epoch 182/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 3.2452 - accuracy: 0.9920\n",
      "Epoch 183/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 2.7516 - accuracy: 0.9929\n",
      "Epoch 184/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 2.7563 - accuracy: 0.9929\n",
      "Epoch 185/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 2.4330 - accuracy: 0.9936\n",
      "Epoch 186/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.7866 - accuracy: 0.9929\n",
      "Epoch 187/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 2.4719 - accuracy: 0.9936\n",
      "Epoch 188/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 2.6074 - accuracy: 0.9931\n",
      "Epoch 189/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.7931 - accuracy: 0.9952\n",
      "Epoch 190/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 3.3934 - accuracy: 0.9914\n",
      "Epoch 191/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.3922 - accuracy: 0.9939\n",
      "Epoch 192/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.6333 - accuracy: 0.9934\n",
      "Epoch 193/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.7448 - accuracy: 0.9929\n",
      "Epoch 194/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.5910 - accuracy: 0.9933\n",
      "Epoch 195/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.7956 - accuracy: 0.9926\n",
      "Epoch 196/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.6485 - accuracy: 0.9937\n",
      "Epoch 197/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 3.6615 - accuracy: 0.9906\n",
      "Epoch 198/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.1065 - accuracy: 0.9948\n",
      "Epoch 199/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 2.3593 - accuracy: 0.9941\n",
      "Epoch 200/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 3.0081 - accuracy: 0.9930\n",
      "Epoch 201/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 2.1982 - accuracy: 0.9943\n",
      "Epoch 202/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.4804 - accuracy: 0.9936\n",
      "Epoch 203/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.0834 - accuracy: 0.9945\n",
      "Epoch 204/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 2.1991 - accuracy: 0.9946\n",
      "Epoch 205/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.1844 - accuracy: 0.9944\n",
      "Epoch 206/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.5460 - accuracy: 0.9939\n",
      "Epoch 207/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 2.5656 - accuracy: 0.9938\n",
      "Epoch 208/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.4716 - accuracy: 0.9940\n",
      "Epoch 209/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.4795 - accuracy: 0.9939\n",
      "Epoch 210/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.4190 - accuracy: 0.9938\n",
      "Epoch 211/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 1.9705 - accuracy: 0.9952\n",
      "Epoch 212/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.5970 - accuracy: 0.9935\n",
      "Epoch 213/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 2.5044 - accuracy: 0.9942\n",
      "Epoch 214/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 1.6079 - accuracy: 0.9960\n",
      "Epoch 215/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 3.4643 - accuracy: 0.9920\n",
      "Epoch 216/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 2.4552 - accuracy: 0.9939\n",
      "Epoch 217/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.1151 - accuracy: 0.9948\n",
      "Epoch 218/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 1.8742 - accuracy: 0.9952\n",
      "Epoch 219/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 2.0490 - accuracy: 0.9949\n",
      "Epoch 220/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.1327 - accuracy: 0.9945\n",
      "Epoch 221/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.0180 - accuracy: 0.9950\n",
      "Epoch 222/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.2236 - accuracy: 0.9944\n",
      "Epoch 223/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.3585 - accuracy: 0.9945\n",
      "Epoch 224/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.6009 - accuracy: 0.9936\n",
      "Epoch 225/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.0449 - accuracy: 0.9948\n",
      "Epoch 226/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.4002 - accuracy: 0.9942\n",
      "Epoch 227/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.9186 - accuracy: 0.9953\n",
      "Epoch 228/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 2.1309 - accuracy: 0.9948\n",
      "Epoch 229/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 2.1579 - accuracy: 0.9949\n",
      "Epoch 230/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.8263 - accuracy: 0.9954\n",
      "Epoch 231/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 2.0366 - accuracy: 0.9950\n",
      "Epoch 232/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.2832 - accuracy: 0.9947\n",
      "Epoch 233/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.6250 - accuracy: 0.9957\n",
      "Epoch 234/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.9124 - accuracy: 0.9952\n",
      "Epoch 235/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.1814 - accuracy: 0.9944\n",
      "Epoch 236/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.1717 - accuracy: 0.9949\n",
      "Epoch 237/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.6219 - accuracy: 0.9960\n",
      "Epoch 238/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.7886 - accuracy: 0.9955\n",
      "Epoch 239/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 1.9201 - accuracy: 0.9954\n",
      "Epoch 240/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.2381 - accuracy: 0.9943\n",
      "Epoch 241/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.3626 - accuracy: 0.9966\n",
      "Epoch 242/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.5192 - accuracy: 0.9961\n",
      "Epoch 243/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.7137 - accuracy: 0.9939\n",
      "Epoch 244/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.1882 - accuracy: 0.9949\n",
      "Epoch 245/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.6458 - accuracy: 0.9957\n",
      "Epoch 246/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.8994 - accuracy: 0.9950\n",
      "Epoch 247/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 2.1850 - accuracy: 0.9945\n",
      "Epoch 248/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 2.0442 - accuracy: 0.9948\n",
      "Epoch 249/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.8084 - accuracy: 0.9956\n",
      "Epoch 250/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.7285 - accuracy: 0.9960\n",
      "Epoch 251/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.8328 - accuracy: 0.9957\n",
      "Epoch 252/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.2061 - accuracy: 0.9945\n",
      "Epoch 253/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.7511 - accuracy: 0.9956\n",
      "Epoch 254/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.4489 - accuracy: 0.9965\n",
      "Epoch 255/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.6218 - accuracy: 0.9960\n",
      "Epoch 256/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.7493 - accuracy: 0.9957\n",
      "Epoch 257/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.7836 - accuracy: 0.9958\n",
      "Epoch 258/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.6937 - accuracy: 0.9958\n",
      "Epoch 259/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.3334 - accuracy: 0.9968\n",
      "Epoch 260/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 2.2350 - accuracy: 0.9943\n",
      "Epoch 261/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.4539 - accuracy: 0.9963\n",
      "Epoch 262/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.5676 - accuracy: 0.9962\n",
      "Epoch 263/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.2390 - accuracy: 0.9971\n",
      "Epoch 264/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 1.8159 - accuracy: 0.9955\n",
      "Epoch 265/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 1.8238 - accuracy: 0.9957\n",
      "Epoch 266/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.6205 - accuracy: 0.9963\n",
      "Epoch 267/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.1838 - accuracy: 0.9947\n",
      "Epoch 268/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.2884 - accuracy: 0.9967\n",
      "Epoch 269/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.1892 - accuracy: 0.9969\n",
      "Epoch 270/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.9173 - accuracy: 0.9959\n",
      "Epoch 271/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.7061 - accuracy: 0.9955\n",
      "Epoch 272/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.9652 - accuracy: 0.9951\n",
      "Epoch 273/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.6073 - accuracy: 0.9961\n",
      "Epoch 274/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.6720 - accuracy: 0.9960\n",
      "Epoch 275/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.4801 - accuracy: 0.9964\n",
      "Epoch 276/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.6552 - accuracy: 0.9963\n",
      "Epoch 277/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 1.6427 - accuracy: 0.9963\n",
      "Epoch 278/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 1.6072 - accuracy: 0.9960\n",
      "Epoch 279/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.5922 - accuracy: 0.9963\n",
      "Epoch 280/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.3454 - accuracy: 0.9966\n",
      "Epoch 281/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.3151 - accuracy: 0.9967\n",
      "Epoch 282/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.1698 - accuracy: 0.9970\n",
      "Epoch 283/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 2.0612 - accuracy: 0.9951\n",
      "Epoch 284/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.5068 - accuracy: 0.9969\n",
      "Epoch 285/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 1.3919 - accuracy: 0.9965\n",
      "Epoch 286/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.8024 - accuracy: 0.9957\n",
      "Epoch 287/500\n",
      "100/100 [==============================] - 12s 123ms/step - loss: 1.4252 - accuracy: 0.9964\n",
      "Epoch 288/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.9548 - accuracy: 0.9976\n",
      "Epoch 289/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.6868 - accuracy: 0.9962\n",
      "Epoch 290/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.7269 - accuracy: 0.9959\n",
      "Epoch 291/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.9423 - accuracy: 0.9956\n",
      "Epoch 292/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.3630 - accuracy: 0.9964\n",
      "Epoch 293/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 1.5742 - accuracy: 0.9960\n",
      "Epoch 294/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.1304 - accuracy: 0.9972\n",
      "Epoch 295/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.4141 - accuracy: 0.9967\n",
      "Epoch 296/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.6623 - accuracy: 0.9962\n",
      "Epoch 297/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.1977 - accuracy: 0.9969\n",
      "Epoch 298/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.1926 - accuracy: 0.9971\n",
      "Epoch 299/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.2592 - accuracy: 0.9969\n",
      "Epoch 300/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.2942 - accuracy: 0.9968\n",
      "Epoch 301/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.1083 - accuracy: 0.9972\n",
      "Epoch 302/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 1.2759 - accuracy: 0.9970\n",
      "Epoch 303/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.1358 - accuracy: 0.9974\n",
      "Epoch 304/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.0420 - accuracy: 0.9975\n",
      "Epoch 305/500\n",
      "100/100 [==============================] - 12s 115ms/step - loss: 1.6894 - accuracy: 0.9961\n",
      "Epoch 306/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.3858 - accuracy: 0.9965\n",
      "Epoch 307/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.2771 - accuracy: 0.9968\n",
      "Epoch 308/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.1848 - accuracy: 0.9971\n",
      "Epoch 309/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.1127 - accuracy: 0.9972\n",
      "Epoch 310/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.3737 - accuracy: 0.9967\n",
      "Epoch 311/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.1052 - accuracy: 0.9972\n",
      "Epoch 312/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.1790 - accuracy: 0.9973\n",
      "Epoch 313/500\n",
      "100/100 [==============================] - 12s 117ms/step - loss: 1.5399 - accuracy: 0.9963\n",
      "Epoch 314/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 1.2556 - accuracy: 0.9970\n",
      "Epoch 315/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.6401 - accuracy: 0.9962\n",
      "Epoch 316/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.6617 - accuracy: 0.9960\n",
      "Epoch 317/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.0085 - accuracy: 0.9973\n",
      "Epoch 318/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.3566 - accuracy: 0.9965\n",
      "Epoch 319/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.3951 - accuracy: 0.9968\n",
      "Epoch 320/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.1231 - accuracy: 0.9975\n",
      "Epoch 321/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.2691 - accuracy: 0.9969\n",
      "Epoch 322/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.0834 - accuracy: 0.9973\n",
      "Epoch 323/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.3375 - accuracy: 0.9967\n",
      "Epoch 324/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.4420 - accuracy: 0.9965\n",
      "Epoch 325/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.6908 - accuracy: 0.9983\n",
      "Epoch 326/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.2652 - accuracy: 0.9971\n",
      "Epoch 327/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.3676 - accuracy: 0.9967\n",
      "Epoch 328/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.1462 - accuracy: 0.9972\n",
      "Epoch 329/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.9196 - accuracy: 0.9977\n",
      "Epoch 330/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.7797 - accuracy: 0.9957\n",
      "Epoch 331/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.2211 - accuracy: 0.9972\n",
      "Epoch 332/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.9241 - accuracy: 0.9975\n",
      "Epoch 333/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.1255 - accuracy: 0.9974\n",
      "Epoch 334/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.3972 - accuracy: 0.9965\n",
      "Epoch 335/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.9492 - accuracy: 0.9978\n",
      "Epoch 336/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.2782 - accuracy: 0.9968\n",
      "Epoch 337/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.3924 - accuracy: 0.9967\n",
      "Epoch 338/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.8979 - accuracy: 0.9977\n",
      "Epoch 339/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.2402 - accuracy: 0.9969\n",
      "Epoch 340/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.5176 - accuracy: 0.9969\n",
      "Epoch 341/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.1815 - accuracy: 0.9972\n",
      "Epoch 342/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.1921 - accuracy: 0.9970\n",
      "Epoch 343/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.2974 - accuracy: 0.9969\n",
      "Epoch 344/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 1.1234 - accuracy: 0.9972\n",
      "Epoch 345/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.3986 - accuracy: 0.9967\n",
      "Epoch 346/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 1.0160 - accuracy: 0.9976\n",
      "Epoch 347/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 0.7897 - accuracy: 0.9981\n",
      "Epoch 348/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.1901 - accuracy: 0.9971\n",
      "Epoch 349/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 1.1917 - accuracy: 0.9974\n",
      "Epoch 350/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.4422 - accuracy: 0.9966\n",
      "Epoch 351/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.8804 - accuracy: 0.9979\n",
      "Epoch 352/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.8732 - accuracy: 0.9979\n",
      "Epoch 353/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.4522 - accuracy: 0.9969\n",
      "Epoch 354/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.2178 - accuracy: 0.9970\n",
      "Epoch 355/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.1902 - accuracy: 0.9972\n",
      "Epoch 356/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.0108 - accuracy: 0.9975\n",
      "Epoch 357/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.0385 - accuracy: 0.9975\n",
      "Epoch 358/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.0279 - accuracy: 0.9976\n",
      "Epoch 359/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 1.1019 - accuracy: 0.9974\n",
      "Epoch 360/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.9003 - accuracy: 0.9977\n",
      "Epoch 361/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.0492 - accuracy: 0.9974\n",
      "Epoch 362/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.4228 - accuracy: 0.9969\n",
      "Epoch 363/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.9449 - accuracy: 0.9977\n",
      "Epoch 364/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 2.0832 - accuracy: 0.9955\n",
      "Epoch 365/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.3924 - accuracy: 0.9968\n",
      "Epoch 366/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.0449 - accuracy: 0.9976\n",
      "Epoch 367/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.0903 - accuracy: 0.9973\n",
      "Epoch 368/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.2507 - accuracy: 0.9970\n",
      "Epoch 369/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 0.8323 - accuracy: 0.9980\n",
      "Epoch 370/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.7834 - accuracy: 0.9980\n",
      "Epoch 371/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 0.8359 - accuracy: 0.9979\n",
      "Epoch 372/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.4487 - accuracy: 0.9964\n",
      "Epoch 373/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.6849 - accuracy: 0.9983\n",
      "Epoch 374/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.8501 - accuracy: 0.9979\n",
      "Epoch 375/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.2251 - accuracy: 0.9971\n",
      "Epoch 376/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.4163 - accuracy: 0.9968\n",
      "Epoch 377/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.2612 - accuracy: 0.9970\n",
      "Epoch 378/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.8517 - accuracy: 0.9981\n",
      "Epoch 379/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.7054 - accuracy: 0.9983\n",
      "Epoch 380/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 0.8392 - accuracy: 0.9980\n",
      "Epoch 381/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 0.8637 - accuracy: 0.9979\n",
      "Epoch 382/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.8361 - accuracy: 0.9979\n",
      "Epoch 383/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 0.8412 - accuracy: 0.9980\n",
      "Epoch 384/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.9687 - accuracy: 0.9963\n",
      "Epoch 385/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.6550 - accuracy: 0.9983\n",
      "Epoch 386/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 1.0001 - accuracy: 0.9976\n",
      "Epoch 387/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.3017 - accuracy: 0.9974\n",
      "Epoch 388/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.9946 - accuracy: 0.9978\n",
      "Epoch 389/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.4130 - accuracy: 0.9965\n",
      "Epoch 390/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.7835 - accuracy: 0.9982\n",
      "Epoch 391/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.8052 - accuracy: 0.9981\n",
      "Epoch 392/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.0488 - accuracy: 0.9975\n",
      "Epoch 393/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.0915 - accuracy: 0.9975\n",
      "Epoch 394/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.5594 - accuracy: 0.9987\n",
      "Epoch 395/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.7706 - accuracy: 0.9981\n",
      "Epoch 396/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 0.7284 - accuracy: 0.9983\n",
      "Epoch 397/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.1767 - accuracy: 0.9977\n",
      "Epoch 398/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.7339 - accuracy: 0.9982\n",
      "Epoch 399/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.9246 - accuracy: 0.9977\n",
      "Epoch 400/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.8553 - accuracy: 0.9979\n",
      "Epoch 401/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.9660 - accuracy: 0.9979\n",
      "Epoch 402/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.7619 - accuracy: 0.9982\n",
      "Epoch 403/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.8277 - accuracy: 0.9980\n",
      "Epoch 404/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.9360 - accuracy: 0.9980\n",
      "Epoch 405/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.1905 - accuracy: 0.9973\n",
      "Epoch 406/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.8232 - accuracy: 0.9963\n",
      "Epoch 407/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.0047 - accuracy: 0.9977\n",
      "Epoch 408/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 1.5156 - accuracy: 0.9972\n",
      "Epoch 409/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.0905 - accuracy: 0.9972\n",
      "Epoch 410/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.4808 - accuracy: 0.9970\n",
      "Epoch 411/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.8012 - accuracy: 0.9981\n",
      "Epoch 412/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.9104 - accuracy: 0.9978\n",
      "Epoch 413/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.2119 - accuracy: 0.9973\n",
      "Epoch 414/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 0.7534 - accuracy: 0.9982\n",
      "Epoch 415/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.7752 - accuracy: 0.9982\n",
      "Epoch 416/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.9116 - accuracy: 0.9980\n",
      "Epoch 417/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.7708 - accuracy: 0.9981\n",
      "Epoch 418/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.9082 - accuracy: 0.9977\n",
      "Epoch 419/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.3918 - accuracy: 0.9970\n",
      "Epoch 420/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.3029 - accuracy: 0.9972\n",
      "Epoch 421/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.8711 - accuracy: 0.9980\n",
      "Epoch 422/500\n",
      "100/100 [==============================] - 12s 118ms/step - loss: 1.0133 - accuracy: 0.9975\n",
      "Epoch 423/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.7113 - accuracy: 0.9982\n",
      "Epoch 424/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.8671 - accuracy: 0.9980\n",
      "Epoch 425/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.7250 - accuracy: 0.9985\n",
      "Epoch 426/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.8555 - accuracy: 0.9982\n",
      "Epoch 427/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.7013 - accuracy: 0.9984\n",
      "Epoch 428/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.6323 - accuracy: 0.9984\n",
      "Epoch 429/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.9226 - accuracy: 0.9977\n",
      "Epoch 430/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.8967 - accuracy: 0.9980\n",
      "Epoch 431/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.5293 - accuracy: 0.9986\n",
      "Epoch 432/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.4649 - accuracy: 0.9965\n",
      "Epoch 433/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.2177 - accuracy: 0.9972\n",
      "Epoch 434/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.4354 - accuracy: 0.9970\n",
      "Epoch 435/500\n",
      "100/100 [==============================] - 12s 115ms/step - loss: 0.8581 - accuracy: 0.9980\n",
      "Epoch 436/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.6519 - accuracy: 0.9984\n",
      "Epoch 437/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.9665 - accuracy: 0.9977\n",
      "Epoch 438/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.7344 - accuracy: 0.9982\n",
      "Epoch 439/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.4411 - accuracy: 0.9988\n",
      "Epoch 440/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.9233 - accuracy: 0.9978\n",
      "Epoch 441/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.6929 - accuracy: 0.9982\n",
      "Epoch 442/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.8765 - accuracy: 0.9981\n",
      "Epoch 443/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.2229 - accuracy: 0.9974\n",
      "Epoch 444/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.6878 - accuracy: 0.9983\n",
      "Epoch 445/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.7121 - accuracy: 0.9983\n",
      "Epoch 446/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.7757 - accuracy: 0.9983\n",
      "Epoch 447/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.5119 - accuracy: 0.9987\n",
      "Epoch 448/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.6249 - accuracy: 0.9985\n",
      "Epoch 449/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.9302 - accuracy: 0.9979\n",
      "Epoch 450/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.9181 - accuracy: 0.9978\n",
      "Epoch 451/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.8937 - accuracy: 0.9980\n",
      "Epoch 452/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.8489 - accuracy: 0.9980\n",
      "Epoch 453/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.8178 - accuracy: 0.9980\n",
      "Epoch 454/500\n",
      "100/100 [==============================] - 12s 123ms/step - loss: 1.4797 - accuracy: 0.9967\n",
      "Epoch 455/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.7357 - accuracy: 0.9983\n",
      "Epoch 456/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.5636 - accuracy: 0.9987\n",
      "Epoch 457/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 0.4897 - accuracy: 0.9987\n",
      "Epoch 458/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.7478 - accuracy: 0.9982\n",
      "Epoch 459/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.1971 - accuracy: 0.9973\n",
      "Epoch 460/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.5921 - accuracy: 0.9985\n",
      "Epoch 461/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.8485 - accuracy: 0.9980\n",
      "Epoch 462/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.2540 - accuracy: 0.9975\n",
      "Epoch 463/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.8655 - accuracy: 0.9979\n",
      "Epoch 464/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.7463 - accuracy: 0.9982\n",
      "Epoch 465/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.8990 - accuracy: 0.9981\n",
      "Epoch 466/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.0925 - accuracy: 0.9976\n",
      "Epoch 467/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.9008 - accuracy: 0.9979\n",
      "Epoch 468/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 0.8281 - accuracy: 0.9979\n",
      "Epoch 469/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 1.3046 - accuracy: 0.9973\n",
      "Epoch 470/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.6886 - accuracy: 0.9984\n",
      "Epoch 471/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.8128 - accuracy: 0.9980\n",
      "Epoch 472/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.5036 - accuracy: 0.9987\n",
      "Epoch 473/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.3617 - accuracy: 0.9991\n",
      "Epoch 474/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.7791 - accuracy: 0.9983\n",
      "Epoch 475/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 0.5797 - accuracy: 0.9985\n",
      "Epoch 476/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.3719 - accuracy: 0.9990\n",
      "Epoch 477/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.9324 - accuracy: 0.9978\n",
      "Epoch 478/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.1095 - accuracy: 0.9977\n",
      "Epoch 479/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.7732 - accuracy: 0.9982\n",
      "Epoch 480/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.4616 - accuracy: 0.9989\n",
      "Epoch 481/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 1.1024 - accuracy: 0.9977\n",
      "Epoch 482/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 1.1668 - accuracy: 0.9974\n",
      "Epoch 483/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.6374 - accuracy: 0.9984\n",
      "Epoch 484/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.7136 - accuracy: 0.9985\n",
      "Epoch 485/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 0.8840 - accuracy: 0.9983\n",
      "Epoch 486/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.4083 - accuracy: 0.9991\n",
      "Epoch 487/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.7822 - accuracy: 0.9982\n",
      "Epoch 488/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.9872 - accuracy: 0.9976\n",
      "Epoch 489/500\n",
      "100/100 [==============================] - 12s 119ms/step - loss: 0.9016 - accuracy: 0.9979\n",
      "Epoch 490/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.6264 - accuracy: 0.9984\n",
      "Epoch 491/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.5708 - accuracy: 0.9986\n",
      "Epoch 492/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.7617 - accuracy: 0.9983\n",
      "Epoch 493/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.9197 - accuracy: 0.9980\n",
      "Epoch 494/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.9103 - accuracy: 0.9980\n",
      "Epoch 495/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.7801 - accuracy: 0.9980\n",
      "Epoch 496/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.5796 - accuracy: 0.9988\n",
      "Epoch 497/500\n",
      "100/100 [==============================] - 12s 121ms/step - loss: 0.6127 - accuracy: 0.9985\n",
      "Epoch 498/500\n",
      "100/100 [==============================] - 12s 122ms/step - loss: 0.7779 - accuracy: 0.9982\n",
      "Epoch 499/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.4010 - accuracy: 0.9990\n",
      "Epoch 500/500\n",
      "100/100 [==============================] - 12s 120ms/step - loss: 0.6048 - accuracy: 0.9985\n"
     ]
    }
   ],
   "source": [
    "data_g = data_generator(32)\n",
    "history = model.fit_generator(data_g,steps_per_epoch=100,epochs=500)\n",
    "np.save(\"rt_loss\",history.history['loss'])\n",
    "np.save(\"rt_history\",history.history['accuracy'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "question: ((56+28)+(81*45)*(47+94)+(53*36))=?\n",
      "\n",
      "\n",
      "computation:\n",
      "81*45 = 3645\n",
      "((56+28)+(81*45)*(47+94)+(53*36)) = ((56+28)+3645*(47+94)+(53*36))\n",
      "53*36 = 1908\n",
      "((56+28)+3645*(47+94)+(53*36)) = ((56+28)+3645*(47+94)+1908)\n",
      "56+28 = 84\n",
      "((56+28)+3645*(47+94)+1908) = (84+3645*(47+94)+1908)\n",
      "47+94 = 141\n",
      "(84+3645*(47+94)+1908) = (84+3645*141+1908)\n",
      "3645*141 = 513945\n",
      "(84+3645*141+1908) = (84+513945+1908)\n",
      "84+513945 = 514029\n",
      "(84+513945+1908) = (514029+1908)\n",
      "(514029+1908) = 515937\n",
      "\n",
      "\n",
      "ground truth = 515937\n"
     ]
    }
   ],
   "source": [
    "equation = generate_expression(3,100)\n",
    "print(f'question: {equation}=?')\n",
    "print(f'\\n')\n",
    "print(f'computation:')\n",
    "compute(equation,False)\n",
    "print(f'\\n')\n",
    "print(f'ground truth = {eval(equation)}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.6.9 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "767d51c1340bd893661ea55ea3124f6de3c7a262a8b4abca0554b478b1e2ff90"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
